package com.aegis.gateway.enums;

import com.aegis.common.enums.PermissionTypeEnum;
import com.aegis.gateway.strategy.FilterDistributeHandler;
import com.aegis.gateway.strategy.SignFilterDistributeHandler;
import com.aegis.gateway.strategy.WhiteListFilterDistributeHandler;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author wuweixin
 * 
 * @Version 1.0
 * @Descritube
 */
@Getter
@AllArgsConstructor
public enum PermissionTypeHandlerEnum {

    WHITE_LIST(PermissionTypeEnum.WHITE_LIST.getType(), "白名单", WhiteListFilterDistributeHandler.class),
    CHECK_SIGN(PermissionTypeEnum.CHECK_SIGN.getType(), "签名校验", SignFilterDistributeHandler.class);

    private final Integer type;
    private final String desc;
    private Class<? extends FilterDistributeHandler> aClass;

    public static PermissionTypeHandlerEnum getEnum(Integer type) {
        for (PermissionTypeHandlerEnum value : values()) {
            if (value.getType().equals(type)) {
                return value;
            }
        }
        throw new IllegalArgumentException("无效的权限类型");
    }

}
